home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_300
/
325_02
/
function.doc
< prev
next >
Wrap
Text File
|
1990-03-26
|
50KB
|
1,891 lines
/* Functions */
OpenGraph
---------
Include : grph.h
Declaration : int far pascal OpenGraph(Byte Mode,Byte Erase)
Parameters : Mode = Bios mode no. to set
Erase = 0 video buffer is cleared
1 video buffer is not cleared
Return : Mode no. if successful.
Usage :
OpenGraph(0x12,0);
This will set Video adapter in mode hex 12, and erase the video buffer.
Description : sets the system in Graphics mode, Video buffer is cleared
if Erase = 0, and not cleared when Erase = 1.
Mode is mapped to BIOS mode no. according to following scheme, which can
be modified in GRPH.H
Mode Resolutions and colors BIOS Mode No
0 640x350x16 0x10
1 640x480x16 0x12
2 320x200x256 0x13
3 640x400x256 0x5c
4 640x480x256 0x5d
5 800x600x16 0x5b
6 1024x768x16 0x5f
Mode Nos. 4 and 6 require 512k video memory.
This function also sets up a no. of graphics state defaults.
Sets up Graphics controller in the requested mode.
Sets current viewport to whole screen, specifically, viewport boundaries
will be (0,0) and (XRes,YRes).
sets up world co-ordinates same as viewport co-ordinates, i. e.
one-to-one mapping between viewport and world co-ordinates.
clipping is enabled, drawing color is 7, fillpattern is Solid-fill
(Fp[19] in PATTERN.H), all drawing styles also solid.
Binary font from file 'v8x8.fnt', and stroked font from file 'sdflt.fnt',
these files should be in the current directory.
CloseGraph
----------
Include : grph.h
Declaration : void far pascal CloseGraph(void)
Usage :
CloseGraph();
This call will, normally, return to text mode.
Description : Resets to Previous mode when OpenGraph was called with
Erase = 0, (Modes are not stacked !)
SetFillPattern
--------------
Include : grph.h
Declaration : void far pascal SetFillPattern(Byte Color,Byte XIndex,
Byte YIndex,void far *Pattern)
Parameters : Color = culor value of fill, either 0 to 255 or 0 to 15
depending upon mode
XIndex = 0-7, Start index from left within Pattern matrix
YIndex = 0-7, start index from top within pattern matrix
Pattern = 8 bytes Pattern array
Usage :
SetFillPattern(8,0,0,Fp[0]);
Will set fill color to 8 (grey), Indexes are zero, and fill pattern
to be used is 1st. pattern of the standard patterns Fp defined in
PATTERN.H.
Description :
This call is used to set either standard or user defined fill patterns,
fill color, and fill pattern indices, so subsequent calls to area
fill routines will use these parameters.
GetFillPattern
--------------
Include : grph.h
Declaration : void far pascal GetFillPattern(void *Color,void *XIndex,
void *YIndex, void far *Pattern)
Parameters : Color = Address of Byte variable, will contain color value
XIndex, YIndex = Addresses of integers
Pattern = Address of 8 byte array to return fill pattern
Usage : GetFillPattern(&clr, &ix, &iy, pattern);
this will return fill pattern parameters in the respective variables
Description : Returns Fill Parameters
SetViewPort
-----------
Include : grph.h
Declaration : void far pascal SetViewPort(struct VP vp1)
Parameters : structure VP type variable vp1 containing corner co-ordinates
of the viewport
Usage :
struct VP vp1;
vp1.x1 = 10;
vp1.y1 = 10;
vp1.x2 = 120;
vp1.y2 = 140;
SetViewPort(VP);
This will set up a view port with upper left corner at (10,10) and
lower right corner at (120,140), in device co-ordinates.
Description :
Sets viewport boundaries, with upper left x , upper left y, lower right x,
lower right y device co-ordinates given by x1,y1,x2,y2 of structure VP.
With clipping enabled, all drawings can be clipped to this viewport
boundary. However, absolute co-ordinates (10,10) will not be translated
to (0,0) in the above given example. This can be achieved by a small
inteface routine of your own, so can the 'Normalised Device Co-ordinates"
be implemented by a small translation routine.
At mode set, by OpenGraph procedure, default viewport is entire screen and
clipping is enabled.
GetViewPort
-----------
Include : grph.h
Declaration : void far pascal GetViewPort(struct VP *vp1)
Parameters : Address of a variable of type structure VP
Usage : GetViewPort(&vp1);
Returns current viewport co-ordinates in vp1.
Description : x1, y1, x2, y2 of structure VP type variable vp1 will
contain co-ordinates of upper left corner and lower right corner of
the current active v. p.
SetXLen
-------
Include : grph.h
Declaration : void far pascal SetXLen(Word Length)
Parameters : Word type Length containing no of bytes.
Usage :
SetXLen(100);
will set video buffer length to 100 bytes.
Description : Re-dimensions video buffer with length as Length Bytes,
and height as 64*1024/Length bytes, only applicable in modes 0x10 and 0x12.
This is like having a drawing area larger than what is displayed on
screen at a time, function SScroll() can be used to scroll display
horizontally or vertically so that portions of video buffer become
visible.
ImageSize
---------
Include : grph.h
Declaration : #define ImageSize(int x1,int y1,int x2,int y2) \
((abs(x2-x1)+1)*(abs(y2-y1)+1)+5)
Parameters : x1,y1 = upper left corner of the image
x2,y2 = lower right corner of the image
Usage :
int isize;
isize = ImageSize(10,10,120,140);
will calculate no of bytes required to store an image (rectangular),
with upper left corner at device co-ordinates (10,10) and lower right
corner at device co-ordinates (120,140)
Description : Calculates No of bytes required to store Bit image bounded
by rectangular region x1,y1,x2,y2, so that memory can be allocated for a
buffer of that size for subsequent bit-block moves.
GetImage
--------
Include : grph.h
Declaration : void far pascal GetImage(int Ulx ,int Uly,int Lrx,int Lry,\
void far *Buffer)
Parameters : Ulx, Uly = co-ordinates of upper left corner
Lrx, Lry = co-ordinates of lower right corner
Buffer = Address of buffer to store Image
Usage :
void far *pB;
pB = (void far *)malloc(ImageSize(10,10,120,140));
GetImage(10,10,120,140,pB);
will calculate size of the image and store it in buffer, the image
bounded by upper left corner at (10,10) and lower right corner at
(120,140).
Description : Returns Bit-Image bounded by rectangular region Ulx,Uly and
Lrx, Lry in Buffer, for subsequent Bit block moves
PutImage
--------
Include : grph.h
Declaration : void far pascal PutImage(int Ulx,int Uly,void far *Buffer)
Parameters : Ulx, Uly = co-ordinates of left corner of position
where to store image.
Buffer = Address of buffer containig bit image, previously
obtained by a call to GetImage, or read from file by a
call to LoadImage.
Usage :
GetImage(10,10,110,110,pB); /* assume pB is allocated */
for (i=10; i<530; i++)
PutImage(i,220,pB);
will put image on screen from pB from x-co-ordinate 10 to 520 and y = 220,
if left vertical edge of the image is same as background, then this will
have an effect of sliding the image from left to right.
Description : Displays Bit Image stored in Buffer, obtained by a call to
GetImage, at (Ulx,Uly) as upper left corner
CopyImage
---------
Include : grph.h
Declaration : void far pascal CopyImage(int Ulx,int Uly,int Lrx,int Lry,\
int x,int y)
Parameters : Ulx, Uly = upper left corner co-ordinates
Lrx, Lry = Lower right corner co-ordinates
x,y = upper left corner do-ordinates of the destination
Usage